package MyGO.dao.impl;

import MyGO.Data.Amount;
import MyGO.Form.TrackForm;
import MyGO.dao.IAmountDao;
import MyGO.utils.FileUtils.FileIO;
import com.fasterxml.jackson.core.type.TypeReference;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class AmountImpl implements IAmountDao {
    private static List<Amount> AMOUNT_LIST = new ArrayList<>();
    static {
//        AMOUNT_LIST.add(new Amount("liyi", "1231", "111"));
//        AMOUNT_LIST.add(new Amount("lier", "123lier", "112"));
//        AMOUNT_LIST.add(new Amount("lisan", "123lisan", "113"));
//        AMOUNT_LIST.add(new Amount("zhangyi", "123zhangyi", "114"));
//        AMOUNT_LIST.add(new Amount("zhanger", "123zhanger", "115"));
//        AMOUNT_LIST.add(new Amount("zhangsan", "123zhangsan", "116"));
//        AMOUNT_LIST.add(new Amount("wangyi", "123wangyi", "117"));
//        AMOUNT_LIST.add(new Amount("wanger", "123wanger", "118"));
//        AMOUNT_LIST.add(new Amount("wangsan", "123wangsan", "119"));
//        AMOUNT_LIST.add(new Amount("jingyi", "123jingyi", "11111111"));
//        AMOUNT_LIST.add(new Amount("jinger", "123jinger", "11111112"));
//        AMOUNT_LIST.add(new Amount("saber", "123saber", "11111113"));
//
        TypeReference<List<Amount>> typeRef = new TypeReference<List<Amount>>() {};
        try {
            AMOUNT_LIST = FileIO.readObjectFromJsonFile("Amount.json", typeRef);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


    @Override
    public List<Amount> getAllAmount() {
        return AMOUNT_LIST;
    }

    @Override
    public void addAmount(Amount amount) {
        AMOUNT_LIST.add(amount);
    }
}
